<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>普通资产流转管理</title>
    <link rel="stylesheet" href="../../js/bower_components/bootstrap/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="../../js/bower_components/bootstrap-select/dist/css/bootstrap-select.min.css">
    <link rel="stylesheet" href="../../js/bower_components/bootstrap-switch/dist/css/bootstrap3/bootstrap-switch.min.css">
    <link rel="stylesheet" href="../../js/bower_components/bootstrap-table/dist/bootstrap-table.min.css">
    <link rel="stylesheet" href="../../js/bower_components/bootstrap-treeview/dist/bootstrap-treeview.min.css">

    <script src="../../js/bower_components/jquery/dist/jquery.min.js"></script>
    <script src="../../js/bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
    <script src="../../js/bower_components/bootbox.min.js"></script>
    <script src="../../js/bower_components/bootstrap-select/js/bootstrap-select.js"></script>
    <script src="../../js/bower_components/bootstrap-switch/dist/js/bootstrap-switch.min.js"></script>
    <script src="../../js/bower_components/bootstrap-table/dist/bootstrap-table.min.js"></script>
    <script src="../../js/bower_components/bootstrap-table/dist/locale/bootstrap-table-zh-CN.js"></script>
    <script src="../../js/bower_components/bootstrap-treeview/dist/bootstrap-treeview.min.js"></script>
    <script src="../../js/bower_components/jquery-form-validator/form-validator/jquery.form-validator.min.js"></script>
    <script src="../../js/bower_components/moment/min/moment-with-locales.min.js"></script>
    <script>

    $(function () {
        $("#btnAdd").click(function () {
            console.log("模态框的打开方法===1");
            $("#divForm").modal();
            console.log("模态框的打开方法===2");
        })
        $("#btnInstockShow").click(function () {
                console.log("模态框的打开方法===3");
                $("#divAssetsInstock").modal();
                console.log("模态框的打开方法===4");
            })
            $("#btnEdit").click(function () {
                console.log("模态框的打开方法===5");
                $("#divAssetsInfo").modal();
                console.log("模态框的打开方法===6");
            })
            $("#btnclose").click(function () {
                console.log("模态框的打开方法===7");
                $("#divAssetsStocking").modal();
                console.log("模态框的打开方法===8");
            })
        
        //搜索按钮
        $("#btnSearch").click(function () {
            console.log("进入搜索按钮的方法");
            //获取界面当中的控件的值
            var form = $("#txt").val();
            console.log(form);
            var formparentid = $("#selparentid").selectpicker('val');
            console.log(formparentid);
            //整理查询条件
            var user = "?";
            if (form != "") {
                user += "=" + form
                if (formparentid != "" || formparentid != "全部") {
                    user += "&parentid=" + formparentid
                }
            }
            else if (formparentid != "") {
                if (formparentid != "全部") {
                    if (user != "") {
                        user += "&parentid=" + formparentid
                    } else {
                        user += "parentid=" + formparentid
                    }
                }
            }

            console.log(user);

            //到后端去查询

            $.ajax({
                type: "get",
                dataType: "json",
                url: "http://121.37.241.58:8883/logic/trans/normal/history/1" + user,
                success: function (res) {
                    inittable(res);
                }
            })
        })

        initparentid();
        inittable("");
        initparentidForm();
    });

    function initparentid() {
        $("#selparentid").empty;
        $.ajax({
            type: "get",
            url: "http://121.37.241.58:8883/logic/trans/normal/history/1",
            dataType: "json",
            success: function (res) {
                console.log(res);
                if (!res.flag) {
                    $.each(res, function (i, n) {
                        $("#selparentid").append("<option value=\"" + n.parentid + "\">" + n.parentid + "</option>")
                    });
                    $("#selparentid").append("<option value='全部'>全部</option>");
                    $("#selparentid").selectpicker('refresh');
                }
            }
        })
    }


    function initparentidForm() {
        $("#selparentidForm").empty;
        $.ajax({
            type: "get",
            url: "http://121.37.241.58:8883/logic/trans/normal/history/1",
            dataType: "json",
            success: function (res) {
                console.log(res);
                if (!res.flag) {
                    $.each(res, function (i, n) {
                        $("#selparentidForm").append("<option value=\"" + n.parentid + "\">" + n.parentid + "</option>")
                    });
                    $("#selparentidForm").selectpicker('refresh');
                }
            }
        })
    }


    function inittable(myData) {
        console.log(myData + ":默认值")
        $("#tblResult").bootstrapTable("destroy");
        var form = $("#txt").val();
        var formparentid = $("#selparentid").selectpicker('val');
        if (myData == "") {
            if (form == "" || formparentid == "") {
                console.log("进入无参的方法")
                $("#tblResult").bootstrapTable({
                    loadMsg: "正在加载数据....",
                    url: "http://121.37.241.58:8883/logic/trans/normal/history/1",
                    //data:res,
                    sidePagination: 'client',
                    pageSize: "5",
                    Pageinatin: true,
                    idField: "id",
                    columns: [{
                        field: "",
                        title: "单位金额",
                        halign: 'center'
                    }, {
                        field: "namecn",
                        title: "资产名称",
                        halign: 'center'
                    }, {
                        field: "parentid",
                        title: "品牌",
                        halign: 'center'
                    }, {
                        field: "comment",
                        title: "供货商",
                        halign: 'center'
                    }, {
                        field: "comment",
                        title: "库存记录",
                        halign: 'center'
                    }
                    ]

                })
            } else {
                console.log("进入无参的方法")

                $("#tblResult").bootstrapTable({
                    loadMsg: "正在加载数据....",
                    //url:"http://121.37.241.58:8883/logic/trans/normal/history/1",
                    data: myData,
                    sidePagination: 'client',
                    pageSize: "5",
                    Pageinatin: true,
                    idField: "id",
                    columns: [{
                        field: "",
                        title: "单位金额",
                        halign: 'center'
                    }, {
                        field: "namecn",
                        title: "资产名称",
                        halign: 'center'
                    }, {
                        field: "parentid",
                        title: "品牌",
                        halign: 'center'
                    }, {
                        field: "comment",
                        title: "型号",
                        halign: 'center'
                    }, {
                        field: "comment",
                        title: "供货商",
                        halign: 'center'
                    }, {
                        field: "comment",
                        title: "库存记录",
                        halign: 'center'
                    }]
                })
            }
        } else {
            console.log("进入条件查询");
            $("#tblResult").bootstrapTable({
                loadMsg: "正在加载数据....",
                //url:"http://121.37.241.58:8883/logic/trans/normal/history/1",
                data: myData,
                sidePagination: 'client',
                pageSize: "5",
                Pageinatin: true,
                idField: "id",
                columns: [{
                    field: "",
                    title: "单位金额",
                    halign: 'center'
                }, {
                    field: "namecn",
                    title: "资产名称",
                    halign: 'center'
                }, {
                    field: "parentid",
                    title: "品牌",
                    halign: 'center'
                }, {
                    field: "comment",
                    title: "型号",
                    halign: 'center'
                }, {
                    field: "comment",
                    title: "供货商",
                    halign: 'center'
                }, {
                    field: "comment",
                    title: "库存记录",
                    halign: 'center'
                }]
            })
        }
    }
</script>
</head>
<body>
    <div class="container-fluid">
		<div class="row">
			<div id="divSearchForm" class="col-md-10">
				<div>
					<label for="spanCategoryGroup">资产分类：</label>
					<span id="spanCategoryGroup">
						<select id="selCategory1">
							<option value="-1"> 全 部 </option>
						</select>
						<select id="selCategory2">
							<option value="-1"> 全 部 </option>
						</select>
					</span>
				</div>
				<div>
					<label for="tbxAssetsName">资产名称：</label>
					<input type="text" id="tbxAssetsName" />
				</div>
				<div>
					<label for="tbxAssetsCode">资产编号：</label>
					<input type="text" id="tbxAssetsCode" />
				</div>
				<div>
					<label for="selPackageType">包装类型：</label>
					<select id="selPackageType">
						<option value="-1"> 全 部 </option>
					</select>
				</div>
				<div>
					<label for="tbxSupplier">供货商信息：</label>
					<input type="text" id="tbxSupplier" />
				</div>
				<div>
					<label for="cbkConsumptive">耗材：</label>
					<input type="checkbox" id="cbkConsumptive" />
				</div>
				<div>
					<button type="button" id="btnSearch" class="btn-primary">
						<span class="glyphicon glyphicon-search" /> 检索  </button>
				</div>
			</div>
			<div class="row">
				<div class="col-md-10">
					<div id="toolsButtons">
						<button type="button" id="btnAdd" class="btn-success">
							<span class="glyphicon glyphicon-plus" /> 新增资产 
						</button>
						<button type="button" id="btnInstockShow" class="btn-primary">
							<span class="glyphicon glyphicon-download-alt" /> 资产入库 
						</button>
						<button type="button" id="btnEdit" class="btn-warning">
							<span class="glyphicon glyphicon-edit" /> 编辑资产 
						</button>
                    </button>

					</div>
				</div>
			</div>
			<div class="row">
				<div class="col-md-10">
					<div id="divResult">
						<table id="tblResult">
							<thead>
								<tr id="resultHeader">
									<th data-halign="center" data-valign="middle">
										<span class="glyphicon glyphicon-tags" /> 资产编号
									</th>
									<th data-halign="center" data-valign="middle">资产名 称</th>
									<th data-halign="center" data-valign="middle"> 品 牌 </th>
									<th data-halign="center" data-valign="middle"> 型 号 </th>
									<th data-halign="center" data-valign="middle">供货商 </th>
									<th data-halign="center" data-valign="middle">库存记录</th>
								</tr>
							</thead>
							<tbody id="resultBody"></tbody>
						</table>
					</div>
				</div>
			</div>
            <div class="modal fade" id="divAssetsInstock" tabindex="-1" parentid="dialog" aria-labelledby="myModal"
            aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content" id="content">
                    <div class="modal-header" id="assetsInstockHead">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> × </button>

                        <h4 class="modal-title" id="modalTitle">资产入库</h4>

                    </div>
                    <div class="modal-body">
                        <form id="formInstock">
                            <input type="hidden" id="hidAssetsIdForInstock" value="" />
                            <div id="divInstockAlert" role="alert"></div>
                            <div id="divInstockContent">
                                <div>
                                    <label for="tbxAssetsNameShow">资产名称：</label>
                                    <div class="input-group">
                                        <input type="text" id="tbxAssetsNameForInstock" readonly="readonly" />
                                    </div>
                                </div>
                                <div>
                                    <label for="tbxInstockCount">入库数量：</label>
                                    <div class="input-group">
                                        <input type="number" min="0" id="tbxInstockCount" required="required" />
                                        <span class="input-group-addon">
                                            <span class="glyphicon glyphicon-asterisk"></span>
                                        </span>
                                    </div>
                                </div>
                                <div>
                                    <label for="tbxInstockPrice">入库单价：</label>
                                    <div class="input-group">
                                        <span class="input-group-addon">￥</span>
                                        <input type="number" min="0" id="tbxInstockPrice" required="required" />
                                        <span class="input-group-addon">
                                            <span class="glyphicon glyphicon-asterisk"></span>
                                        </span>
                                    </div>
                                </div>
                                <div>
                                    <label for="tbxInstockSum">金额合计：</label>
                                    <div class="input-group">
                                        <span class="input-group-addon">￥</span>
                                        <input type="text" readonly="readonly" min="0" id="tbxTotalPrice" />
                                    </div>
                                </div>
                                <div>
                                    <label for="tbxInstockDate">入库时间：</label>
                                    <div class="input-group">
                                        <input type="date" id="tbxInstockDate" required="required" />
                                        <span class="input-group-addon">
                                            <span class="glyphicon glyphicon-asterisk"></span>
                                        </span>
                                    </div>
                                </div>
                                <div>
                                    <label for="selHandlerEmp">资产购置人：</label>
                                    <div class="input-group">
                                        <select id="selHandlerEmp" required="required"> </select>
                                    </div>
                                </div>
                                <div>
                                    <label for="tbxInstockComment">备注说明：</label>
                                    <div class="input-group">
                                        <textarea rows="2" id="tbxInstockComment"> </textarea>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                    
                    <div class="modal-footer">
                        <button class="btn-primary" id="btnInstock">
                            <span class="glyphicon glyphicon-save"> 入库 Instock </button>
                        <button class="btn-default" data-dismiss="modal" id=" btnCancelInstock">
                            <span class="glyphicon glyphicon-remove"> 取消 Cancel
                        </button>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal fade" id="divForm" tabindex="-1" parentid="dialog" aria-labelledby="myModal"
            aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title" id="modalTitle">新增资产</h4>
                    </div>
                    <div class="modal-body form-inline">
                        <div class="form-group">
                            <label class="control-label" for="txtorganization">购买机构</label>
                            <input type="text" id="txtorganization" style="width: 200px;" class="form-control" />
                        </div>
                        <div class="form-group">
                            <label class="control-label" for="txtrefBankNo">关联账号</label>
                            <input type="text" id="txtrefBankNo" style="width: 200px;" class="form-control" />
                        </div>
                        <div class="form-group">
                            <label class="control-label" for="selFinanceType">资产分类</label>
                            <select id="selFinanceType"></select>
                        </div>

                        <div class="modal-footer">
                            <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                            <button type="button" class="btn btn-primary">保存</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="modal fade" id="divAssetsInfo" tabindex="-1" parentid="dialog" aria-labelledby="myModal"
            aria-hidden="true">
            <div class="modal-dialog">
                <div class="modal-content" id="assetsInfoContent">
                    <div class="modal-header" id="assetsInfoHead">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> × </button>
                        <h4 class="modal-title" id="modalTitle">资产信息</h4>
                    </div>
                    <div class="modal-body">
                        <form id="formAssetsInfo">
                            <input type="hidden" id="hidAssetsId" value="" />
                            <div id="divEditAlert" role="alert"></div>
                            <div id="divEditContent">
                                <div>
                                    <label for="tbxAssetsCodeEdit">资产编号：</label>
                                    <div class="input-group">
                                        <input type="text" id="tbxAssetsCodeEdit" readonly="readonly" />
                                    </div>
                                </div>
                                <div>
                                    <label for="tbxAssetsNameEdit">资产名称：</label>
                                    <div class="input-group">
                                        <input type="text" id="tbxAssetsNameEdit" required="required" />
                                        <span class="input-group-addon">
                                            <span class="glyphicon glyphicon-asterisk"></span>
                                        </span>
                                    </div>
                                </div>
                                <div>
                                    <label for="spanCategoryGroupEdit"> 资产分 类 : </label>
                                    <div class="input-group">
                                        <div>
                                            <select id="selCategoryEdit1" required="required"></select>
                                            <select id="selCategoryEdit2" required="required"></select>
                                        </div>
                                    </div>
                                </div>
                                <div>
                                    <label for="selPackageTypeEdit">包装类型：</label>
                                    <div class="input-group">
                                        <select id="selPackageTypeEdit"></select>
                                    </div>
                                </div>
                                <div>
                                    <label for="tbxNormalBrandEdit">品牌：</label>
                                    <div class="input-group">
                                        <input type="text" id="tbxNormalBrandEdit" required="required" />
                                        <span class="input-group-addon">
                                            <span class="glyphicon glyphicon-asterisk"></span>
                                        </span>
                                    </div>
                                </div>
                                <div>
                                    <label for="tbxNormalModelEdit">型号：</label>
                                    <div class="input-group">
                                        <input type="text" id="tbxNormalModelEdit" required="required" />
                                        <span class="input-group-addon">
                                            <span class="glyphicon glyphicon-asterisk"></span>
                                        </span>
                                    </div>
                                </div>
                                <div>
                                    <label for="tbxSupplierEdit">供货商名称：</label>
                                    <div class="input-group">
                                        <input type="text" id="tbxSupplierEdit" required="required" />
                                        <span class="input-group-addon">
                                            <span class="glyphicon glyphicon-asterisk"></span>
                                        </span>
                                    </div>
                                </div>
                                <div>
                                    <label for="tbxSupplierTelEdit">供货商电话：</label>
                                    <div class="input-group">
                                        <input type="tel" id="tbxSupplierTelEdit" required="required" />
                                        <span class="input-group-addon">
                                            <span class="glyphicon glyphicon-asterisk"></span>
                                        </span>
                                    </div>
                                </div>
                                <div>
                                    <label for="cbkConsumptiveEdit">耗材：</label>
                                    <div class="input-group">
                                        <input type="checkbox" id="cbkConsumptiveEdit" required="required" />
                                    </div>
                                </div>
                                <div>
                                    <label for="tbxCommentEdit">其他说明：</label>
                                    <div class="input-group">
                                        <textarea rows="2" id="tbxCommentEdit"> </textarea>
                                    </div>
                                </div>
                            </div>
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button class="btn-primary" id="btnSaveAssets">
                            <span class="glyphicon glyphicon-floppy-saved" /> 保 存 Save</button>
                        <button class="btn-default" data-dismiss="modal" id="btnCancel"> 90
                            <span class="glyphicon glyphicon-remove" /> 取 消 Cancel</button>
                    </div>
                </div>
            </div>
        </div>
        <div id="divTransHistory" tabindex="-1" role="dialog" aria-labelledby="assetsInstockTitle"
                aria-hidden="true">
                <div class="modal-dialog modal-lg">
                    <div id="content" class="modal-content">
                        <div id="transHistoryHead" class="modal-header">
                            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"> × </button>
                            <h4 class="modal-title" id="transHistoryTitle"><span
                                    class="glyphicon glyphicon-equalizer"></span>资
                                产流转记录 </h4>
                        </div>
                        <div class="modal-body">
                            <table id="tblTransHistory"> </table>
                        </div>
                        <div class="modal-footer">
                            <div id="divAssetsStocking">
                                合计入库数量：<span id="spanInstockCount"></span>
                                合计出库数量：<span id="spanDeliveryCount"></span>
                                当前库存合计：<span id="spanStockCount"></span>
                            </div>
                        </div>
                    </div>
                </div>
            </div>



						
</body>
</html>